home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.1 KB | 70 lines | [TEXT/GEOL] |
- Item 2793943 24-Aug-90 16:21PDT
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: POWERUP.DEV Power Up Software,PRT
-
- cc: MACAPP.TECH$ MacApp Technical
-
- Sub: Re: RE>>Multiple Inheritance
-
- Meyer has a good discussion of reuse by inheritance or by instance in his book
- (section 14.5 "Would you rather buy or inherit?"). Also, in section 10.2.2 he
- says that inheritance represents the "is-a" relationship.
-
- He also uses the example where the class FIXED_STACK inherits from STACK (an
- abstract class) and ARRAY, so as to use ARRAY's implementation (section
- 10.4.1). In this case, note that the features of ARRAY are not exported. (At
- least that's what it looks like to me; I'm not an Eiffel expert.) This means
- that FIXED_STACK is not a subtype of ARRAY.
-
- As far as the design is concerned, there is no difference between inheriting
- from ARRAY (and not exporting its features) and using an instance of ARRAY in
- the implementation. The interface to the FIXED_STACK class is the same in
- either case.
-
- The title of the section ("The marriage of convenience") is telling. It looks
- to me that he did this either because it is more efficient that way or easier
- to program (fewer characters to type), not because it is a better design.
-
- In the past, I gave a reason why Meyer's approach in this particular case can
- be undesirable. If FIXED_STACK inherits from ARRAY to provide its
- implementation, it is explicitly tied to that implementation. If it uses an
- instance of ARRAY internally, it is free to use different implementations in
- different instances, or even dynamically change its implementation.
-
- Meyer mentions this in section 14.5, when he says that inheriting is a more
- committing decision.
-
-
- Regarding Geoff's example:
-
- One way to handle this might be to make TTrackingGridView a subclass of
- TTrackingView, and have it contain an instance of TGridView. TTrackingGridView
- would also have to implement the GridView methods and delegate to the embedded
- GridView instance.
-
- The reason this might work is that (as far as Geoff has explained it) nothing
- in the scenario depends on TTrackingGridView being a subtype of TGridView, but
- TDesktopDragger does depend on it being a subtype of TTrackingView.
-
- It wouldn't be hard to add to the example something that would require
- TTrackingGridView to be a subtype of TGridView, and then this implementation
- would no longer work. You would definitely need multiple inheritance.
-
- Note that multiple inheritance isn't a panacea in this case either. You would
- end up having to make a TTrackingxxxView class for each existing TxxxView
- class. The problem is that the tracking features really does belong in the
- TView class.
-
- As far as the future of MacApp goes, I don't know. I don't see it moving into
- C++, in the immediate future. I think there are still a lot of developers who
- prefer to use Pascal, so that MacApp has to support both languages. Until
- there is an implementation of Pascal++, I think MacApp will be constrained to
- the common subset of langauge features.
-
- Larry
-
-
-
-